# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=spyder-kernels
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=2.1.3
pkgrel=2
pkgdesc='Jupyter Kernels for the Spyder console (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('MIT')
url='https://github.com/spyder-ide/spyder-kernels'
depends=(
    ${MINGW_PACKAGE_PREFIX}-python
    ${MINGW_PACKAGE_PREFIX}-python-cloudpickle
    ${MINGW_PACKAGE_PREFIX}-python-ipykernel
    ${MINGW_PACKAGE_PREFIX}-python-ipython
    ${MINGW_PACKAGE_PREFIX}-python-jupyter_client
    ${MINGW_PACKAGE_PREFIX}-python-jupyter_core
    ${MINGW_PACKAGE_PREFIX}-python-pyzmq)
makedepends=(
    ${MINGW_PACKAGE_PREFIX}-python-setuptools)
source=("https://github.com/spyder-ide/${_realname}/archive/v${pkgver}.tar.gz")
sha256sums=('529d75968a3bcfe9c9389c8c703aea116a4d1c100b28f0135217c07186f7024e')

prepare() {
  cd "${srcdir}"
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  sed -i "s/jupyter-client>=5.3.4,<7/jupyter-client>=5.3.4/g" setup.py
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
